package com.java.zhuiyun.api.teacher.contoller;


import com.java.zhuiyun.api.teacher.model.TeacherModel;
import com.java.zhuiyun.api.teacher.service.TeacherService;
import com.java.zhuiyun.common.response.CommonResult;
import com.java.zhuiyun.util.pageUtil.PageRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BackCourseController
 * @Description TODO
 * @Author 杨友朋
 * @Date 2023/8/14 15:18
 **/
@RestController
@CrossOrigin
@RequestMapping("/teacher")
public class TeacherController {
    @Resource
    TeacherService teacherService;

    /**
     * @Author 杨友朋
     * @Description TODO 添加教师信息
     * @Date 2023/8/15 11:14
     * @Return
     * @param
     */
    @PostMapping("/addTeacher")
    public CommonResult addTeacher(MultipartFile file1, MultipartFile file2,TeacherModel teacher){
        return teacherService.addTeacher(file1,file2,teacher);
    }

    /**
     * @Author 杨友朋
     * @Description TODO 全查教师
     * @Date 2023/8/15 11:14
     * @Return
     * @param
     */
    @GetMapping("/selectTeacher")
    public CommonResult selectTeacher(TeacherModel teacherModel, PageRequest pageRequest){
        return CommonResult.ok(teacherService.selectTeacher(teacherModel, pageRequest));
    }

    /**
     * @Author 杨友朋
     * @Description TODO 根据id查询教师
     * @Date 2023/8/15 11:14
     * @Return
     * @param
     */
    @GetMapping("/selectTeacherById")
    public CommonResult selectTeacherById(Integer id){
        return teacherService.selectTeacherById(id);
    }

    /**
     * @Author 杨友朋
     * @Description TODO 查询学历菜单
     * @Date 2023/8/16 8:35
     * @Return
     * @param
     */
    @GetMapping("/selectEducationDict")
    public CommonResult selectEducationDict(){

        return CommonResult.ok(teacherService.selectEducationDict());
    }

    /**
    * @Author 杨友朋
    * @Description TODO 删除教师
    * @Date 2023/8/16 19:30
    * @Return
    * @param
    */
    @GetMapping("/delTeacher")
    public CommonResult delTeacher(Integer id){

        return teacherService.delTeacher(id);
    }

    /**
    * @Author 杨友朋
    * @Description TODO 修改教师
    * @Date 2023/8/16 20:09
    * @Return
    * @param
    */
    @PostMapping("/upTeacher")
    public CommonResult upTeacher(MultipartFile file1, MultipartFile file2, TeacherModel teacher){
        return teacherService.upTeacher(file1,file2,teacher);
    }

}
